 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title><spring:message code="message.lable.DICguiGeChaKan"/></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
    <script src="lib/js/html5shiv.min.js"></script>
    <script src="lib/js/respond.min.js"></script>
<![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
  
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    <div class="form-group form-group-xs">
                        <label for="txtDrugName"><spring:message code="message.listForm.GuiGeBianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <input class="form-control" type="text" id="txtSpecCode" name="txtSpecCode" placeholder="<spring:message code="message.listForm.GuiGeBianMa"/>" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="txtDrugForm"><spring:message code="message.listForm.GuiGeMingCheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <input class="form-control" type="text" id="txtSpecName" name="txtSpecName" placeholder="<spring:message code="message.listForm.GuiGeMingCheng"/> "/>
                    </div>
                   
                    <button type="button" onclick="likeQuery();" class="btn btn-success btn-sm" id="selectSpec"><spring:message code="message.button.seachSpacing"/></button>
                </div>
            </div>
        </div>
       <table class="jqgrid" id="gridlist"></table>
       <div id="gridpage"></div>
       <div class=" box box-warning bottongroup">
            <button type="button" id="confirm"  onclick="confirm();" class="btn btn-default btn-sm"><spring:message code="message.button.okSpacing"/></button>
        </div>
      
        
    </section>
   
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
  //绑定回车
    $('#txtSpecCode,#txtSpecName').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectSpec').click();
        }
    }); 
        $(function () {
        	$("#txtSpecName").focus();//加载页面光标在规格名称
            $("#gridlist").jqGrid({
                url: "${ctx}/stdDrugQualitySpec/getStdDrugQualitySpecDrugSpec.html",
                mtype: "POST",
                datatype: "json",
                postData:{"spec":"${spec}"},
                autowidth: true,
                height: 270,
                colNames: ['specId','<spring:message code="message.listForm.GuiGeBianMa"/>', '<spring:message code="message.listForm.GuiGeMingCheng"/>'],
                colModel: [
                    { name: 'spec',hidden:true, width: 80,align:"center",sortable: false},
                    { name: 'specCode', width: 100,align:"center",sortable: false },
                    { name: 'specName', width: 120,align:"center",sortable: false  },
                    
                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
               // multiselect: true, 
                caption: "<spring:message code="message.list.drugspecDiclist"/>",
                gridComplete:function(){
                	//序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                	//数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                },
                jsonReader: {
                    repeatitems: false,
                    id: "spec"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            
           
        });
        
      //查询
        function likeQuery(page) {
        	var specCode  = $("#txtSpecCode").val();
            var specName = $("#txtSpecName").val();
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:{
                	"specCode":specCode,
                    "specName":specName},
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
        
        
        //确认
        function confirm() {
            var rowId = $("#gridlist").jqGrid("getGridParam", "selrow") || [];
             if(rowId.length <=0){
                $.alert("<spring:message code="message.lable.pleaseSelectOperational"/><spring:message code="message.listForm.guiGe"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return;
             }
             var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
             var dialog = top.dialog.get(window);
             var params = {
                "spec" : rowdata.spec,
                "specCode" : rowdata.specCode,
                "specName" : rowdata.specName,
             };
             dialog.close(params);   // 关闭（隐藏）对话框
             dialog.remove();        // 主动销毁对话框
        }
       
    </script>
</body>
</html>